<template>
	<div class="liveWinners w944">
		<div class="label_top">
			<button @click="reBack"><i><&nbsp;</i>返回</button>
			<p>{{updateTitle}}——获奖名单</p>
		</div>
		<div class="label_table">
			<div class="el-tabs-report">
				<span><b>获奖人数：</b>{{totalItems}}人</span>
				<a class="listTwo" @click="importDaoChu()">导出数据</a>
			</div>
			<el-table ref="multipleTable" :data="tableData" border>
				<el-table-column label="序号" width="60">
					<template slot-scope="scope">{{ scope.row.sort}}</template>
				</el-table-column>
				<el-table-column prop="viewerName" label="用户名称"></el-table-column>
				<el-table-column prop="winnerCode" label="中奖码"></el-table-column>
				<el-table-column prop="prize" label="中奖礼品"></el-table-column>
				<el-table-column prop="createdTime" label="中奖时间"></el-table-column>
				<el-table-column prop="extName" label="获奖者信息"></el-table-column>
				<el-table-column prop="extPhone" label="电话"></el-table-column>
				<el-table-column prop="extAddress" label="地址"></el-table-column>
			</el-table>
			<div style="margin-top: 30px">
				<div class="pag_block">
					<el-pagination @current-change="handleCurrentChange" :current-page="currentpage" :page-size="pagesize" layout="prev, pager, next" :total="total"></el-pagination>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	export default{
		data(){
			return{
				updateTitle:'',
				liveColumnTitle:'',
				teacherTitle:'',
				lecturerid:'',
				liveBroadcastid:'',
				pageTypeNum:'',
				courseCompanyid:'',
				liveType:'',
				tableData:[],
				information:'',
				telephone:'',
				address:'',
				totalItems:0,
				sort:'',
				pagesize: 15,
				currentpage: 1,
				total: 1
			}
		},
		methods:{
			getParams() {
				this.updateTitle = this.$route.params.updateTitle;
				this.liveColumnTitle = this.$route.params.liveColumnTitle;
				this.liveBroadcastid = this.$route.params.liveBroadcastid;
				this.pathKey = this.$route.params.pathKey;
				this.liveId = this.$route.params.liveId;
				this.liveType = this.$route.params.liveType;
				this.teacherTitle = this.$route.params.teacherTitle;
				this.lecturerid = this.$route.params.lecturerid;
				console.log('liveWinners:',this.$route.params);
			},
			getWinnerList(){
				this.$ajax({
					url: this.$root.jifuUrl + "/getLotteryList?"+ 'page=' + this.currentpage + '&num=' + this.pagesize + '&liveBroadcastid=' + this.liveBroadcastid,
					method: 'GET',
					data: {},
					success: res => {
						console.log(res);
						if(res.data.code == 200) {
							this.tableData = res.data.data.list;
							for(var i = 0;i<this.tableData.length;i++){
								this.tableData[i].sort=i+1
							};
							this.total=res.data.data.pageParam.items;
							this.totalItems = this.total;
						}
					}
				});
			},
			handleCurrentChange(value) {
				// 当前页码
				this.currentpage = value;
				this.getWinnerList();
			},
			reBack(){
				this.$router.push({
					name: this.liveType,
					params: {
						liveId:this.liveId,
						updateTitle:this.liveColumnTitle,
						pathKey:this.pathKey,
						liveId:this.liveId,
						teacherTitle:this.teacherTitle,
						lecturerid:this.lecturerid
					}
				})
			}
		},
		mounted(){
			this.getParams();
			if(this.liveBroadcastid==null){
				this.$store.commit('GET_liveWinners');
				var s =this.$store.state.liveWinners;
				this.updateTitle=s.updateTitle;
				this.liveColumnTitle = s.liveColumnTitle;
				this.liveBroadcastid=s.liveBroadcastid;
				this.pathKey = s.pathKey;
				this.liveId = s.liveId;
				this.liveType = s.liveType;
				this.teacherTitle = s.teacherTitle;
				this.lecturerid = s.lecturerid;
			};
			this.getWinnerList();
			window.addEventListener("beforeunload",()=>{
				s={
					updateTitle:this.updateTitle,
					liveColumnTitle:this.liveColumnTitle,
					liveBroadcastid:this.liveBroadcastid,
					pathKey:this.pathKey,
					liveId:this.liveId,
					liveType:this.liveType,
					teacherTitle:this.teacherTitle,
					lecturerid:this.lecturerid
				}	
				this.$store.commit('SET_liveWinners', s);
			});
		}
	}
</script>
<style>
	.liveWinners{padding-bottom: 100px;}
	.liveWinners .el-table .cell,.liveWinners .el-table th div,.liveWinners .el-table--border td:first-child .cell,.liveWinners .el-table--border th:first-child .cell {padding:0;text-align:center;}
</style>
 